<article class="cl pd-20">
    <form action="" method="post" class="form form-horizontal" id="form">
        <div class="row cl">
            <label class="form-label col-xs-2 col-sm-2"><span class="c-red"></span>文字：</label>
            <div class="formControls col-xs-10 col-sm-10">
                <input type="text" class="input-text" value="{$swiper.text}" placeholder="" name="text">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-2 col-sm-2"><span class="c-red"></span>链接：</label>
            <div class="formControls col-xs-10 col-sm-10">
                <input type="text" class="input-text" value="{$swiper.url}" placeholder="" name="url">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-2 col-sm-2"><span class="c-red"></span>排序号：</label>
            <div class="formControls col-xs-10 col-sm-10">
                <input type="number" class="input-text" value="{$swiper.ord}" placeholder="" name="ord">
                <span>数字越大越靠前</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-2 col-sm-2"><span class="c-red"></span>图片：</label>
            <div class="formControls col-xs-10 col-sm-10">
                <div class="uploader-thum-container">
                    <div id="upload-list" class="uploader-list">
                        {if $swiper['imgurl']}
                        <img src="<?=$swiper['imgurl']?>"/>
                        {/if}
                    </div>
                    <input type="hidden" id="upload-input" name="imgurl"  value="<?php echo $swiper['imgurl']?>" class="input-text">
                    <div id="filePicker">
                        <a id="upload" class="webuploader-pick btn btn-primary">选择图片</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-10 col-sm-10 col-xs-offset-2 col-sm-offset-2">
                <a onclick="submit()" class="btn btn-primary radius" >&nbsp;&nbsp;提交&nbsp;&nbsp;</a>
            </div>
        </div>
    </form>
</article>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
   function submit () {
        $('#form').ajaxSubmit(function(res){
            if(res.ret==0) {
                layer.open({
                    content:res.message,
                    yes:function(){
                        layer.closeAll();
                        parent.location.reload();
                    }
                })
            }else{
                layer.msg(res.message);
            }
        });
    }
</script>
<script src="https://cdn.bootcss.com/plupload/3.1.0/plupload.js"></script>
<script type="text/javascript">
MXI_DEBUG = false;
var ids = new Array("upload");
$.each(ids,function(i,n){
    var self = this.toString();
    var uploader = new plupload.Uploader({
        browse_button: self, // this can be an id of a DOM element or the DOM element itself
        url: '/admin/config/uploadpic',
        multi_selection: false,
        filters: {
            mime_types : [
                { title : "Image files", extensions : "jpg,gif,png,jpeg" }
            ]
        },
        init: {
            FilesAdded: function (e) {
                layer.load();//正在加载
                uploader.start();
            },
            FileUploaded: function (up, file, info) {
                layer.closeAll('loading');//关闭正在加载
                var res = JSON.parse(info.response);
                if(res.ret==0) {
                    var img = "<img src='"+res.data+"'/>";
                    $('#'+self+'-list').html(img);
                    $('#'+self+'-input').val(res.data);
                }
            }
        }
    });
uploader.init();
});

</script>
